package jdkc;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/*
 *@Student 张策
 */
public class JDBC2 {
    public static void main(String[] args) throws Exception {
        //导入对应的数据库驱动jar包
        //注册驱动
        Class.forName("com.mysql.jdbc.Driver");
        //获取数据库连接对象
        Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/db6", "root", "111111");
        //定义sql语句
        String sql="insert into acc values(null,'zc',44441)";
        //获取执行sql的对象 Statement
        Statement state = conn.createStatement();
        //执行sql
        int count = state.executeUpdate(sql);
        System.out.println(count);
        //释放资源
        state.close();
        conn.close();
    }
}
